﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Models;
using DAL;

namespace BLL
{
    public class LoginUserBll
    {
        /// <summary>
        /// 创建单个用户
        /// </summary>
        /// <returns></returns>
        public bool InsertSingleData(LoginUserModel lum)
        {
            return new LoginUserDal().InsertSingleData(lum);
        }
        //<summary>
        //根据code码修改单位信息
        //</summary>
        //<param name = "code" ></ param >
        //< returns ></ returns >
        public string[] SetManageByCode(string UnitCode, string userId)
        {
            return new LoginUserDal().SetManageByCode(UnitCode, userId);
        }


        /// <summary>
        /// 将单位信息关联到账户表，并将第一个关联的用户设置为管理员
        /// </summary>
        /// <param name="departId"></param>
        /// <param name="departName"></param>
        /// <param name="userID"></param>
        /// <returns></returns>
        public bool UpdateDepartInfo(string departId, string departName, string userID)
        {
            return new LoginUserDal().UpdateDepartInfo(departId, departName, userID);
        }

        /// <summary>
        /// 根据OpenId获取单挑数据
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public LoginUserModel GetSingleDataByOpenId(string openId)
        {
            return new LoginUserDal().GetSingleDataByOpenId(openId);
        }


        /// <summary>
        /// 根据userid或者openId获取单条数据
        /// </summary>
        /// <param name="userNo"></param>
        /// <returns></returns>
        public LoginUserModel GetSingleDataByUserNo(string userNo)
        {
            return new LoginUserDal().GetSingleDataByUserNo(userNo);
        }
        /// <summary>
        /// 根据userId获取单挑数据
        /// </summary>
        /// <param name="userId"></param>
        /// <returns></returns>
        public LoginUserModel GetSingleDataByUserId(string userId)
        {
            return new LoginUserDal().GetSingleDataByUserId(userId);
        }

        /// <summary>
        /// 根据userId修改是否为管理员（0不是管理员，1是管理员）
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="isManager"></param>
        /// <returns></returns>
        public bool UpdateManager(string userId, string isManager)
        {
            return new LoginUserDal().UpdateManager(userId,isManager);
        }
            /// <summary>
            /// 根据userAccount获取单挑数据
            /// </summary>
            /// <param name="userId"></param>
            /// <returns></returns>
            public LoginUserModel GetSingleDataByUserAccount(string userAccount)
        {
            return new LoginUserDal().GetSingleDataByUserAccount(userAccount);
        }



        /// <summary>
        /// 根据userid或者Openid或者用户账号获取当前用户是否是管理员
        /// </summary>
        /// <param name="userNo"></param>
        /// <returns></returns>
        public bool IsManager(string userNo)
        {
            return new LoginUserDal().IsManager(userNo);
        }

        /// <summary>
        /// 根据id获取人员信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public EmployeeModel GetEmployeeById(string id)
        {
            return new LoginUserDal().GetEmployeeById(id);
        }

        /// <summary>
        /// 根据人员id获取图片
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public AttachmentModel GetAttachmentById(string parentId)
        {
            return new LoginUserDal().GetAttachmentById(parentId);
        }

        /// <summary>
        /// 根据departId判断是否存在单位信息
        /// </summary>
        /// <param name="departId"></param>
        /// <returns></returns>
        public int SetDeaprt(string departId, string userId)
        {
            return new LoginUserDal().SetDeaprt(departId, userId);
        }

        public List<LoginUserModel> GetDataList()
        {
            return new LoginUserDal().GetDataList();
        }

        /// <summary>
        /// 根据id删除单挑数据
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool DelSingleDataById(string id)
        {
            return new LoginUserDal().DelSingleDataById(id);
        }


        /// <summary>
        /// 根据userId修改昵称
        /// </summary>
        /// <param name="nickName"></param>
        /// <param name="userId"></param>
        /// <returns></returns>
        public bool UpdateNickName(string nickName, string userId)
        {
            return new LoginUserDal().UpdateNickName(nickName,userId);
        }
        }
}
